<template>
  <div class="user-management-container">
    <!-- <vab-query-form>
      <vab-query-form-left-panel :span="12">
        <el-date-picker
          v-model="PayTime"
          end-placeholder="结束日期"
          range-separator="至"
          start-placeholder="开始日期"
          style="margin-left: 20px"
          type="daterange"
          @change="GetzhifuTime"
        />
      </vab-query-form-left-panel>

      <vab-query-form-right-panel :span="12">
        <el-form :inline="true" :model="queryForm" @submit.native.prevent>
          <el-form-item>
            <el-input
              v-model.trim="queryForm.keyWord"
              clearable
              placeholder="请输入用户名"
            />
          </el-form-item>
          <el-form-item>
            <el-button icon="el-icon-search" type="primary" @click="queryData">
              查询
            </el-button>
          </el-form-item>
        </el-form>
      </vab-query-form-right-panel>
    </vab-query-form> -->

    <el-table
      v-loading="listLoading"
      border
      :data="list"
      :row-style="rowStyle"
      style="width: 100%"
      @selection-change="setSelectRows"
    >
      <el-table-column align="center" show-overflow-tooltip type="selection" />
      <el-table-column
        align="center"
        label="id"
        prop="userId"
        show-overflow-tooltip
      />
      <el-table-column
        align="center"
        label="姓名"
        prop="name"
        show-overflow-tooltip
        width="250"
      >
        <template slot-scope="scope">
          {{ scope.row.name }}
          <el-tooltip
            class="item"
            content="这是演员当前分数"
            effect="dark"
            placement="right"
          >
            <el-button>{{ scope.row.actorScore }}分</el-button>
          </el-tooltip>
          <br />
          <template v-if="scope.row.locked == 0">
            <span style="color: green">未锁定</span>
          </template>
          <template v-if="scope.row.locked == 1">
            <span style="color: red">已锁定</span>
          </template>
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        label="所属领队"
        prop="enterpriseName"
        show-overflow-tooltip
      />
      <el-table-column align="center" label="演员头像">
        <template slot-scope="scope">
          <img class="tupian" :src="scope.row.actorPicture" />
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        label="手机号"
        prop="phone"
        show-overflow-tooltip
      />
      <el-table-column
        align="center"
        label="身高"
        prop="height"
        show-overflow-tooltip
      />
      <el-table-column
        align="center"
        label="体重"
        prop="weight"
        show-overflow-tooltip
      />
      <el-table-column
        align="center"
        label="出生年月"
        prop="birthday"
        show-overflow-tooltip
      />
      <el-table-column align="center" label="实名信息">
        <template slot-scope="scope">
          {{ scope.row.name }}
          <br />
          <img
            class="el-avatar el-avatar--circle"
            :src="scope.row.headPortrait"
          />
        </template>
      </el-table-column>
      <el-table-column align="center" label="实名认证" show-overflow-tooltip>
        <template slot-scope="scope">
          <template v-if="scope.row.realName == 0">
            <span style="color: red">未认证</span>
          </template>
          <template v-else-if="scope.row.realName == 1">
            <span style="color: red">待审核</span>
          </template>
          <template v-if="scope.row.realName == 2">
            <span style="color: green">审核通过</span>
          </template>
          <template v-else-if="scope.row.realName == 3">
            <span style="color: red">未通过</span>
          </template>
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        label="民族"
        prop="minzu"
        show-overflow-tooltip
      />
      <el-table-column
        align="center"
        label="常住城市"
        prop="stayCity"
        show-overflow-tooltip
      />
      <el-table-column
        align="center"
        label="参演作品"
        prop="inWork"
        show-overflow-tooltip
      />
      <el-table-column
        align="center"
        label="创建时间"
        prop="creationTime"
        show-overflow-tooltip
      />

      <el-table-column align="center" label="身份认证" show-overflow-tooltip>
        <template slot-scope="scope">
          <template v-if="scope.row.authActor == 0">
            <span style="color: red">未认证</span>
          </template>
          <template v-else-if="scope.row.authActor == 1">
            <span style="color: red">待审核</span>
          </template>
          <template v-if="scope.row.authActor == 2">
            <span style="color: green">审核通过</span>
          </template>
          <template v-else-if="scope.row.authActor == 3">
            <span style="color: red">未通过</span>
          </template>
        </template>
      </el-table-column>

      <template #empty>
        <el-image
          class="vab-data-empty"
          :src="require('@/assets/empty_images/data_empty.png')"
        />
      </template>
    </el-table>
    <el-pagination
      background
      :current-page="queryForm.pageNum"
      :layout="layout"
      :page-size="queryForm.pageSize"
      :total="total"
      @current-change="handleCurrentChange"
      @size-change="handleSizeChange"
    />
    <!-- <edit ref="edit" @fetch-data="fetchData" /> -->
  </div>
</template>

<script>
  import { gettwoList } from '@/api/yanyuan'
  // import Edit from './components/yanyuanedit.vue'

  export default {
    name: 'UserManagement',
    components: {},
    data() {
      return {
        PayTime: '',
        value: '',
        meetdata: '', //接受传过来的当前分数
        options1: [
          {
            id: '0',
            creClasName: '未审核',
          },
          {
            id: '1',
            creClasName: '待审核',
          },
          {
            id: '2',
            creClasName: '审核通过',
          },
          {
            id: '3',
            creClasName: '审核未通过',
          },
        ], //审核状态
        list: [],
        listLoading: true,
        layout: 'total, sizes, prev, pager, next, jumper',
        total: 0,
        selectRows: '',
        queryForm: {
          pageNum: 1,
          pageSize: 10,
          leaderCheck: '',
          keyWord: '', //chaxun
          starTime: '', //开始时间
          endTime: '', //结束时间
        },
      }
    },
    // watch: {
    //   // 如果 `searchfilename` 发生改变，这个函数就会运行
    //   // PayTime: function () {
    //   //   if (this.PayTime == '') {
    //   //     this.fetchData()
    //   //   }
    //   // },
    //   PayTime: {
    //     //如果是浅层次的就直接写上变量名不用，深层次的必须加上引号包起来""
    //     // 数据发生变化就会调用这个函数
    //     handler(newVal) {
    //       console.log('nrw', newVal)
    //       console.log(newVal == null)
    //       if (newVal == null) {
    //         console.log('ewrewrew')
    //         this.fetchData()
    //       }
    //     },
    //     // 立即处理 进入页面就触发
    //     immediate: true,
    //     deep: true, // 深度监听，监听到更深层级值的变化
    //   },
    // },
    created() {
      this.fetchData()
    },
    methods: {
      // handleDelete(row) {
      //   console.log('rowid', row.id)
      //   console.log('rowroled', row.id)
      //   // 停用
      //   if (row.id) {
      //     this.$baseConfirm('你确定要停用当前项吗', null, async () => {
      //       const { msg } = await genggai({ id: row.id })
      //       this.$baseMessage(msg, 'success', 'vab-hey-message-success')
      //       await this.fetchData()
      //     })
      //   }
      // },
      // tableRowClassName({ row, rowIndex }) {
      //   console.log('row', row.locked)
      //   console.log('rowIndex', rowIndex)
      //   if (row.locked == 1) {
      //     return 'warning-row'
      //   }
      //   // } else if (rowIndex === 3) {
      //   //   return 'success-row'
      //   // }
      // },

      rowStyle({ row }) {
        if (row.locked === 1) {
          return {
            background: '#d3d7e0',
            color: '#d3d7e0',
          }
        }
      },

      setSelectRows(val) {
        this.selectRows = val
      },
      getfenshu(val) {
        this.meetdata = val
      },
      handleAdd(row) {
        //打分管理
        this.$refs['Editfenpei'].showEdit(row)
      },
      handleEdit(row) {
        if (row.id) {
          this.$refs['edit'].showEdit(row)
        } else {
          this.$refs['edit'].showEdit()
        }
      },
      handleEdittwo(row) {
        if (row.id) {
          this.$refs['Edittwo'].showEdit(row)
        } else {
          this.$refs['Edittwo'].showEdit()
        }
      },
      handleEditthree(row) {
        if (row.id) {
          this.$refs['Editxiangqing'].showEdit(row)
        } else {
          this.$refs['Editxiangqing'].showEdit()
        }
      },
      handleEditfour(row) {
        if (row.id) {
          this.$refs['Editxiugai'].showEdit(row)
        } else {
          this.$refs['Editxiugai'].showEdit()
        }
      },
      // handleDelete(row) {
      //   if (row.id) {
      //     this.$baseConfirm('你确定要删除当前项吗', null, async () => {
      //       const { msg } = await doDelete({ ids: row.id })
      //       this.$baseMessage(msg, 'success', 'vab-hey-message-success')
      //       await this.fetchData()
      //     })
      //   } else {
      //     if (this.selectRows.length > 0) {
      //       const ids = this.selectRows.map((item) => item.id).join()
      //       this.$baseConfirm('你确定要删除选中项吗', null, async () => {
      //         const { msg } = await doDelete({ ids })
      //         this.$baseMessage(msg, 'success', 'vab-hey-message-success')
      //         await this.fetchData()
      //       })
      //     } else {
      //       this.$baseMessage('未选中任何行', 'error', 'vab-hey-message-error')
      //     }
      //   }
      // },
      handleSizeChange(val) {
        this.queryForm.pageSize = val
        this.fetchData()
      },
      async optosall(e) {
        this.queryForm.leaderCheck = e.id
        // this.listLoading = true
        // this.queryForm.pageNum = 1
        // const res = await gettwoList(this.queryForm)
        // this.list = res.data.dataList
        // this.listLoading = false
      },
      handleCurrentChange(val) {
        this.queryForm.pageNum = val
        this.fetchData()
      },
      queryData() {
        this.queryForm.pageNum = 1
        this.fetchData()
      },
      //支付时间戳设置
      GetzhifuTime() {
        // console.log(typeof this.PayTime)
        if (this.PayTime) {
          this.queryForm.starTime = this.PayTime[0]
          this.queryForm.endTime = this.PayTime[1]
        }
        // this.listLoading = true
        // this.queryForm.pageNum = 1
        // const res = await gettwoList(this.queryForm)
        // this.list = res.data.dataList
        // this.listLoading = false
      },

      // async fetchData() {
      //   this.listLoading = true
      //   const {....
      //     data: { list, total },
      //   } = await gettwoList(this.queryForm)
      //   this.list = list
      //   this.total = total
      //   this.listLoading = false
      // },
      async fetchData() {
        this.listLoading = true
        const res = await gettwoList(this.queryForm)
        console.log(res)
        this.list = res.data.dataList
        this.total = res.data.total
        this.listLoading = false
      },
    },
  }
</script>
<style>
  .el-table .warning-row {
    background: #f0f9eb;
  }

  .el-table .success-row {
    background: #f0f9eb;
  }
</style>
